package com.tensquare.base.controller;

import entity.Result;
import entity.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器.
 *
 * @author 宫新程
 * @since 2019/3/2 11:45
 */
@Slf4j
@RestControllerAdvice
public class BaseExceptionHandler {

  @ExceptionHandler(value = Exception.class)
  public Result exception(Exception e) {
    log.error("异常错误：{}", e.getMessage());
    return new Result(false, StatusCode.ERROR, e.getMessage());
  }
}
